libostree: Rework OstreeAsyncProgress to use GVariants internally
authorPhilip Withnall <withnall@endlessm.com>
Fri, 28 Apr 2017 15:06:40 +0000 (16:06 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Sat, 29 Apr 2017 11:50:15 +0000 (11:50 +0000)
commitf74e52a3a0c441f8e56b796d99c492b1a0a2072c
tree098bb25facde6a6e18632c4cfcf63c930c128e45
parente60b9bc0492358d41e9646df608a40c3f6729f7c
libostree: Rework OstreeAsyncProgress to use GVariants internally

OstreeAsyncProgress currently does some contortions to try and avoid
allocating space for guints and guint64s (on 64-bit platforms), but this
means it uses two GHashTables. A GHashTable allocates 8 buckets even
when empty. Given that the largest usage of OstreeAsyncProgress in
libostree puts 13 uints and 5 uint64s in it, this optimisation does not
save significant (if any) memory.

Instead, change OstreeAsyncProgress to store values internally as
GVariants, and expose this with some new API:
 • ostree_async_progress_get_variant()
 • ostree_async_progress_set_variant()
Each GVariant is allocated on the heap. As they are immutable, they are
thread-safe once returned by a getter.

The existing API continues to work as before, except in the case where a
key is set/got as both a uint and a uint64 — there will now be a
collision (and a GVariant type checking failure) whereas previously
there was no collision. Nothing in OSTree uses OstreeAsyncProgress this
way though.

The new API can be used to share more complex data via the progress API.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #819
Approved by: cgwalters
apidoc/ostree-sections.txt
src/libostree/libostree.sym
src/libostree/ostree-async-progress.c
src/libostree/ostree-async-progress.h